﻿@model dynamic

@{
    ResFile = "cms_Content";
}

@functions
{
    string IsSelected(int currentVal, int val)
    {
        return currentVal == val ?
            @"selected=""selected""" :
            string.Empty;
    }
}

<div class="b-form b-form_narrow b-form_bordered b-form_theme_white">
    <div class="b-form__head">
        <fieldset class="b-form">
	        <ol class="b-form__rows ul-reset g-clear">         
                <li class="b-form__row g-clear">
        	        <label for="Category">@_("Category")</label>
                    <select name="CategoryId" class="cms-js-entity-category" multiple="multiple" data-placeholder="Select category(ies)">
                        @foreach (var item in Model.AllCategories)
                        {
                        <option value="@item.Id" @IsSelected(Model.CategoryId, item.Id)>@item.Category</option>
                        }
                    </select>
                    <button id="cms-js-show-content-categories" class="b-button b-button_small" type="button" value="Categories">@_("All categories")</button>
                    <div class="hide">
                        <div id="cms-js-content-categories" class="b-form_fancybox">
                            @{Html.RenderAction("AllCategories", "cmscontenttype", new { id = @Model.ContentTypeId }); }
                        </div>
                    </div>
                </li>
            </ol>
        </fieldset>
    </div>
</div>